package com.serbulent.examples.rest.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;

import org.codehaus.jackson.map.annotate.JsonSerialize;

import com.serbulent.examples.rest.model.util.json.CustomDateSerializer;
import com.thoughtworks.xstream.annotations.XStreamAlias;

@XStreamAlias( "author" )
@Entity
public class Author implements Serializable
{
	private static final long serialVersionUID = 1L;
	
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	int id;

	@Version
	@Column(name = "version")
	private Integer version;
	
	@NotNull
	String name;
	
	@NotNull
	Date birthDay;
	
	public Author() {
		super();
	}
	
	public Author(String name, Date birthDay) {
		super();
		this.name = name;
		this.birthDay = birthDay;
	}
	
	public Integer getVersion() {
		return version;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@JsonSerialize(using = CustomDateSerializer.class)
	public Date getBirthDay() {
		return birthDay;
	}
	public void setBirthDay(Date birthDay) {
		this.birthDay = birthDay;
	}
	
}
